package com.newmainsoftech.aspectjutil.eventmanager.testmodels;

import java.util.List;

import com.newmainsoftech.aspectjutil.eventmanager.EventInfo;

/**
 * Purpose to be used to log the incidence of @OnEvent methods' execution. 
 * From this class, any reference to test model @EventListener class should not be made. The reason is 
 * to avoid triggering loading of test model @EventListener class when this class is loaded. 
 */
public class EventTraceSupporter {
	/**
	 * All test model @EventListener classes will log the incidence of @OnEvent methods' execution 
	 * in eventTraceList. Thereby, test classes refer to any of those test model @EventListener classes 
	 * should initialize this eventTraceList (before each test method execution.)
	 */
	protected static List<String> eventTraceList = null;
	synchronized public static void setEventTraceList( List<String> eventTraceList) {
		EventTraceSupporter.eventTraceList = eventTraceList;
	}
	public static final List<String> getEventTraceList() {
		return eventTraceList;
	}
	public static final void clearEventTraceList() {
		eventTraceList.clear();
	}
	
	protected static List<Object> eventerTraceList = null;
	public static final List<Object> getEventerTraceList() {
		return eventerTraceList;
	}
	synchronized public static final void setEventerTraceList( List<Object> eventerTraceList) {
		EventTraceSupporter.eventerTraceList = eventerTraceList;
	}

	protected static List<Object> eventResultTraceList = null;
	public static final List<Object> getEventResultTraceList() {
		return eventResultTraceList;
	}
	synchronized public static final void setEventResultTraceList( List<Object> eventResultTraceList) {
		EventTraceSupporter.eventResultTraceList = eventResultTraceList;
	}
	
	protected static List<Class<?>> triggeredEventTraceList = null;
	public static final List<Class<?>> getTriggeredEventTraceList() {
		return triggeredEventTraceList;
	}
	synchronized public static final void setTriggeredEventTraceList( List<Class<?>> triggeredEventTraceList) {
		EventTraceSupporter.triggeredEventTraceList = triggeredEventTraceList;
	}
	
	synchronized public static void saveEventInfo( EventInfo eventInfo) {
		EventTraceSupporter.getTriggeredEventTraceList().add( eventInfo.getTriggeredEvent());
		EventTraceSupporter.getEventResultTraceList().add( eventInfo.getResult());
		EventTraceSupporter.getEventerTraceList().add( eventInfo.getEventerInfo());
	}
}
